package com.ruoyi.member.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.member.domain.MemberRate;
import com.ruoyi.member.service.IMemberRateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员评分Controller
 *
 * @author ruoyi
 * @date 2025-01-29
 */
@RestController
@RequestMapping("/member/memberRate")
public class MemberRateController extends BaseController
{
    @Autowired
    private IMemberRateService memberRateService;

    /**
     * 查询会员评分列表
     */
    @PreAuthorize("@ss.hasPermi('member:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberRate memberRate)
    {
        startPage();
        List<MemberRate> list = memberRateService.selectMemberRateList(memberRate);
        return getDataTable(list);
    }

    /**
     * 导出会员评分列表
     */
    @PreAuthorize("@ss.hasPermi('member:rate:export')")
    @Log(title = "会员评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberRate memberRate)
    {
        List<MemberRate> list = memberRateService.selectMemberRateList(memberRate);
        ExcelUtil<MemberRate> util = new ExcelUtil<MemberRate>(MemberRate.class);
        util.exportExcel(response, list, "会员评分数据");
    }

    /**
     * 获取会员评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:rate:query')")
    @GetMapping(value = "/{memberRateId}")
    public AjaxResult getInfo(@PathVariable("memberRateId") Integer memberRateId)
    {
        return success(memberRateService.selectMemberRateByMemberRateId(memberRateId));
    }

    /**
     * 删除会员评分
     */
    @PreAuthorize("@ss.hasPermi('member:rate:remove')")
    @Log(title = "会员评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberRateIds}")
    public AjaxResult remove(@PathVariable Integer[] memberRateIds)
    {
        return toAjax(memberRateService.deleteMemberRateByMemberRateIds(memberRateIds));
    }
}
